package  
{
	import org.flixel.*;
	
	import states.*;
	
	/**
	 * ...
	 * @author JAC
	 */
	public class MusicPlayer 
	{
		public static const MENU:uint = 0;
		public static const TOMB:uint = 1;
		public static const TOMB_FAST:uint = 2;
		public static const CREDITS:uint = 3;
		
		private static var offset:Number;
		
		public static function play(ID:uint):void
		{
			if (FlxG.music != null)
			{
				if (FlxG.music.ID != ID)
				{
					FlxG.music.stop();
					FlxG.playMusic(music(ID), Registry.musicVolume * offset);
				}
			}
			else
			{
				FlxG.playMusic(music(ID), Registry.musicVolume * offset);
			}
			FlxG.music.ID = ID;
		}
		
		private static function music(ID:uint):Class
		{
			switch (ID)
			{
				case MENU:
				{
					offset = 1;
					return Assets.SndMenu;
				}
				case TOMB:
				{
					offset = 0.5;
					return Assets.SndTomb;
				}
				case TOMB_FAST:
				{
					offset = 0.5;
					return Assets.SndTombFast;
				}
				case CREDITS:
				{
					offset = 0.25;
					return Assets.SndCredits;
				}
				default:
				{
					return null;
				}
			}
		}
	}
}